package com.dkd.easybook.controller;
import java.util.List;
import javax.servlet.http.HttpServletResponse;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.dkd.common.annotation.Log;
import com.dkd.common.core.controller.BaseController;
import com.dkd.common.core.domain.AjaxResult;
import com.dkd.common.enums.BusinessType;
import com.dkd.easybook.domain.EbAccountCategoryDefault;
import com.dkd.easybook.service.IEbAccountCategoryDefaultService;
import com.dkd.common.utils.poi.ExcelUtil;
import com.dkd.common.core.page.TableDataInfo;
/**
 * 系统默认记账类别Controller
 *
 * @author itheima
 * @date 2024-12-13
 */
@Api(tags = "系统默认记账类别Controller")
@RestController
@RequestMapping("/easybook/sysAccountCat")
public class EbAccountCategoryDefaultController extends BaseController {
    @Autowired
    private IEbAccountCategoryDefaultService ebAccountCategoryDefaultService;

    /**
     * 查询系统默认记账类别列表
     */
    @ApiOperation("查询系统默认记账类别列表")
    @PreAuthorize("@ss.hasPermi('easybook:sysAccountCat:list')")
    @GetMapping("/list")
    public TableDataInfo list(EbAccountCategoryDefault ebAccountCategoryDefault) {
        startPage();
        List<EbAccountCategoryDefault> list = ebAccountCategoryDefaultService.selectEbAccountCategoryDefaultList(ebAccountCategoryDefault);
        return getDataTable(list);
    }
    /**
     * 导出系统默认记账类别列表
     */
    @ApiOperation("导出系统默认记账类别列表")
    @PreAuthorize("@ss.hasPermi('easybook:sysAccountCat:export')")
    @Log(title = "系统默认记账类别", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, EbAccountCategoryDefault ebAccountCategoryDefault) {
        List<EbAccountCategoryDefault> list = ebAccountCategoryDefaultService.selectEbAccountCategoryDefaultList(ebAccountCategoryDefault);
        ExcelUtil<EbAccountCategoryDefault> util = new ExcelUtil<EbAccountCategoryDefault>(EbAccountCategoryDefault.class);
        util.exportExcel(response, list, "系统默认记账类别数据");
    }
    /**
     * 获取系统默认记账类别详细信息
     */
    @ApiOperation("获取系统默认记账类别详细信息")
    @PreAuthorize("@ss.hasPermi('easybook:sysAccountCat:query')")
    @GetMapping(value = "/{categoryId}")
    public AjaxResult getInfo(@PathVariable("categoryId") Long categoryId) {
        return success(ebAccountCategoryDefaultService.selectEbAccountCategoryDefaultByCategoryId(categoryId));
    }
    /**
     * 新增系统默认记账类别
     */
    @ApiOperation("新增系统默认记账类别")
    @PreAuthorize("@ss.hasPermi('easybook:sysAccountCat:add')")
    @Log(title = "系统默认记账类别", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody EbAccountCategoryDefault ebAccountCategoryDefault) {
        return toAjax(ebAccountCategoryDefaultService.insertEbAccountCategoryDefault(ebAccountCategoryDefault));
    }
    /**
     * 修改系统默认记账类别
     */
    @ApiOperation("修改系统默认记账类别")
    @PreAuthorize("@ss.hasPermi('easybook:sysAccountCat:edit')")
    @Log(title = "系统默认记账类别", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody EbAccountCategoryDefault ebAccountCategoryDefault) {
        return toAjax(ebAccountCategoryDefaultService.updateEbAccountCategoryDefault(ebAccountCategoryDefault));
    }
    /**
     * 删除系统默认记账类别
     */
    @ApiOperation("删除改系统默认记账类别")
    @PreAuthorize("@ss.hasPermi('easybook:sysAccountCat:remove')")
    @Log(title = "系统默认记账类别", businessType = BusinessType.DELETE)
    @DeleteMapping("/{categoryIds}")
    public AjaxResult remove(@PathVariable Long[] categoryIds) {
        return toAjax(ebAccountCategoryDefaultService.deleteEbAccountCategoryDefaultByCategoryIds(categoryIds));
    }
}
